﻿using Autofac;
using Autofac.Extras.DynamicProxy;
using LiuQiuRong.Chat.Infrastructures.Dependencies;
using LiuQiuRong.Chat.Infrastructures.Interceptors;

namespace LiuQiuRong.Chat.Infrastructures.Modules
{
    public class ServicesModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterAssemblyTypes(Initialize.ReferencedAssemblies).PublicOnly()
               .Where(type => !type.IsAbstract && typeof(IService).IsAssignableFrom(type))
                .AsImplementedInterfaces()
                .EnableInterfaceInterceptors()
                .InterceptedBy(typeof(TransactionInterceptor))
                .InstancePerLifetimeScope();
        }
    }
}
